
  <?php 
include('../../Connections/KRAPPERCON.php');

$oper = getVal('oper');
$select = getVal('select');

if ($oper == 'query'){

?>
 <table width="100%" border="1" cellspacing="0" class="tableIn tblSort" id="tbl_qvlc" cellpadding="0">
 <thead>
  <tr>
  <?php 
  	if ($select == 'X'){
  ?>
    <th scope="col">&nbsp;</th>
    <?php 
	}
	?>
    <th scope="col">Serie</th>
    <th scope="col">Placa</th>
    <th scope="col">VIN</th>
    <th scope="col">Marca</th>
    <th scope="col">Motor</th>
    <th scope="col">Fab.</th>
    <th scope="col">Mod.</th>
    <th scope="col">Combustible</th>
  </tr>
  </thead>
  <tbody>
  <?php 
	//$serie = getVal('serie');
	$placa = getVal('placa');
	$vin = getVal('vin');
	$motor = getVal('motor');
	$marca = getVal('marca');
	$client = getVal('cliente');
	$and = '';	
	$where = '';
	$wh_placa = isNull($placa,"VehPlaca = '".$placa."'");
	$where = $wh_placa;
	
	if (!isEmpty($where)) $and = ' and ';
	$wh_vin = isNull($vin,$and."VehVin = '".$vin."'");
	$where=$where.' '.$wh_vin;
	
	if (!isEmpty($where)) $and = ' and ';
	$wh_marca = isNull($marca,"a.MarcaID = '".$marca."'");
	$where = $where.' '.$wh_marca;
	
	if (!isEmpty($where)) $and = ' and ';
	$wh_motor = isNull($motor,$and."VehNroMor='".$motor."'");
	$where = $where.' '.$wh_motor;
	
	if (!isEmpty($where)) $and = ' and ';
	$wh_cliente = isNull($client,$and." a.ClientID = '".$client."'");
	$where = $where.' '.$wh_motor;
	
	if (!isEmpty($where)){
		$where = ' where '.$where;
	}
	
	$sql = 'SELECT VehID,VehPlaca,VehVIN,VehAnFab,VehAnMod,VehPoMot,a.MarcaID,VehFeReg,ClientID,UserID,
	VehTiCom,VehNroMot,VehObs,MarcaTxt FROM tt_vehiculo a inner join tt_marca b on b.MarcaID = a.MarcaID '.$where;
	doEcho($sql);
	$res = $mysqli->query($sql);
	
	$a1 = '';
	$a2 = '';
	
	
	if ($res){
		while($row=$res->fetch_assoc()){
?>
  <tr>
	<?php if ($select == 'X'){	
    ?>
    <td align="center">
    <input type="radio" name="radio" class="clsRbVlc" id="rb_sel_vl" >
    </td>
    <?php 
    }
	else {
	$a1 = '<a href="#" class="a">';
	$a2 = '</a>';
	}
    ?>
    <td class="clsSer">	<?php echo $a1.$row['VehID'].$a2; ?></td>
    <td class="clsPla"><?php echo $row['VehPlaca']; ?></td>
    <td><?php echo $row['VehVIN'];?></td>
    <td class="clsMar"><?php echo $row['MarcaTxt'];?></td>
    <td class="clsMot"><?php echo $row['VehNroMot'];?></td>
    <td><?php echo $row['VehAnFab'];?></td>
    <td><?php echo $row['VehAnMod'];?></td>
    <td><?php echo $row['VehTiCom'];?></td>
  </tr>
<?php 			
		}
	$res->close();
	$mysqli->check_result();
	}	
?>
 </tbody>
</table>

<?php 
}
?>
<script type="text/javascript">
$("#tbl_qvlc tbody .a").each(function(){
	this.href = '#page/Mantenimientos/MantVeh.php?oper=view&type=S&vehiculo='+this.innerHTML;
});
</script>